package com.zzx.test.thread.juc;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName: NotifyTest
 * @Description: notify方法测试
 * @Author zhouzhixin
 * @Date 2021/11/2
 * @Version 1.0
 */
public class NotifyTest0 {

    public static void main(String[] args) {
        Test0 test = new Test0();
        new Thread(test::printA, "A").start();
        new Thread(test::printB, "B").start();
        new Thread(test::printC, "C").start();
    }

}

class Test0 {

    public synchronized void printA() {
        try {
            System.out.println(Thread.currentThread().getName() + "1");
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public synchronized void printB() {
        try {
            System.out.println(Thread.currentThread().getName() + "2");
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (Exception e) {
            e.printStackTrace();
        }    }

    public synchronized void printC() {
        try {
            System.out.println(Thread.currentThread().getName() + "3");
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (Exception e) {
            e.printStackTrace();
        }    }

}
